import pymysql
  

class MySqlHelper():
    def __init__(self,db,ip='192.168.1.233',port=3306,uid='silvertransfer',pwd='fcu89jyp'):
        self.conn = pymysql.connect(host=ip,port=port,
            user=uid,
            password=pwd,
            db=db,
            charset='utf8')

    def excute(self,query,isColumn=True):
        result = None
        if isColumn:
            cursor = self.conn.cursor(cursor=pymysql.cursors.DictCursor)
        else:
            cursor = self.conn.cursor()
        cursor.execute(query)
        result = cursor.fetchall()
        cursor.close()
        return result

    def commit(self):
        self.conn.commit()

    def get_count(self,tbl):
        return self.excute(f'SELECT COUNT(*) FROM {tbl}',False)[0][0]

    def close(self):
        self.conn.close()

sql = MySqlHelper('silvertransferdb')
print(sql.excute('select * from tblusersilvertransferinfail'))
